<?php
/*ini_set('display_errors','1'); ini_set('display_startup_errors','1'); */
/*************************************************************************
Index module
----------------------------------------------------------------
Vnnavi CMS Project
Company: Ava Co., Ltd                                  
Email: kimque@ava.vn                                    
Last updated: 08/03/201
**************************************************************************/
include_once(ROOT_PATH.'classes/dao/ads.class.php');
$ads = new Ads();
$support = new Support();
$template->assign('ads',$ads);
$template->assign('usertemplate',$userTemplate);
$template->assign("ROOTPATH",ROOTPATH);
$orderby =array('position'=>'ASC');
$template->assign('orderby',$orderby);
#chuyen muc sp
include_once(ROOT_PATH."classes/dao/procategories.class.php");
$productcategories = new ProductCategories();
$productcatItems = $productcategories->getObjects(1,"status =1 AND pid=0",array('position'=>'ASC'),'');
$template->assign('productcatItems',$productcatItems);
// cbo search product
$listcbosearch = $productcategories->optionAllCategories('id','vn_name','',"pid=0");
$template->assign('listcbosearch',$listcbosearch);

$template->assign('productcategories',$productcategories);

#supprot
# Phong kinh doanh
$supportItems = $support->getObjects(1,"status =1 AND paid = 5",array('position'=>'ASC'),'');
$template->assign('supportItemsKD',$supportItems);
# Phong ky thuat
$supportItems = $support->getObjects(1,"status =1 AND paid = 7",array('position'=>'ASC'),'');
$template->assign('supportItemsKT',$supportItems);
#end support

#chuyen muc tin tuc
include_once(ROOT_PATH."classes/dao/categories.class.php");
$categories = new Categories();
$categoriesItems = $categories->getObjects(1,"status =1 AND pid=0 AND avatar=1",array('position'=>'ASC'),3);
$template->assign('categoriesItems',$categoriesItems);
#end tin tuc noi bat


#chinh sach ban hang
$sub_idcate1=$categories->getSubCategory1(14); 
$csbanhangItems = $entries->getObjects(1,"status =1 AND cid in($sub_idcate1)",array('date_created'=>'DESC'),3);
$template->assign('csbanhangItems',$csbanhangItems);  
#end chinh sach ban hang
#dich vu sửa chữa
$sub_idcate2=$categories->getSubCategory1(12); 
$dvsuachuaItems = $entries->getObjects(1,"status =1 AND cid in($sub_idcate2)",array('id'=>'ASC'),'');
$template->assign('dvsuachuaItems',$dvsuachuaItems);  
#end dich vu sửa chữa

#tim tuc left
include_once(ROOT_PATH."classes/dao/weblinks.class.php");
$weblinks = new Weblinks();
$leftweblinks = $weblinks->getObjects(1,"status =1",array('position'=>'ASC'),'');
$template->assign('leftweblinks',$leftweblinks);
$template->assign('weblinks',$weblinks);
#end tin tuc left

# Quang cáo
include_once(ROOT_PATH."classes/dao/ads.class.php");
$ads = new Ads();
#Banner
$adsItems = $ads->getObjects(1,"status =1 AND gid = 8",array('id'=>'DESC'),'');
$template->assign('adsItems',$adsItems);

#Banner ben phai
$adsItemsBenPhai = $ads->getObjects(1,"status =1 AND gid = 12",array('id'=>'DESC'),'');
$template->assign('adsItemsBenPhai',$adsItemsBenPhai);

#Banner chay ben trai
$adsItemsL = $ads->getObjects(1,"status =1 AND gid = 13",array('id'=>'DESC'),'');
$template->assign('adsItemsL',$adsItemsL);

#Banner chay ben phai
$adsItemsR = $ads->getObjects(1,"status =1 AND gid = 14",array('id'=>'DESC'),'');
$template->assign('adsItemsR',$adsItemsR);	

#Banner chay ben phai
$adsbannerTopHeader = $ads->getObjects(1,"status =1 AND gid =16",array('id'=>'DESC'),1);
$template->assign('adsbannerTopHeader',$adsbannerTopHeader);	
#popup
$popupItems = $ads->getObjects(1,"status =1 AND gid =17",array('id'=>'DESC'),1);
$template->assign('popupItems',$popupItems);	

#end popup

# Khach hang
include_once(ROOT_PATH."classes/dao/imgbanners.class.php");
$imgbanners = new Imgbanners();
$objImgbanners = $imgbanners->getObjects(1,"status =1",array('position'=>'ASC'),'');
$template->assign('objImgbanners',$objImgbanners);

# Ghi file cache
$body_header = $template->fetch($userTemplate.'/body_header.tpl.html');
$footer = $template->fetch($userTemplate.'/footer.tpl.html');
file_put_contents(ROOT_PATH.'/templates/vtpv/body_header_cache.tpl.html', $body_header);
file_put_contents(ROOT_PATH.'/templates/vtpv/footer_cache.tpl.html', $footer);	

die("Cache thành công. Click <a href='http://phongvu.vn/quanly' title='quanly'>vào đây</a> để trở về trang quản lý");	